﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls">

    <!--BEGIN EXPANDER-->
    <Style x:Key="ControlButtonExpanderPin" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid Width="19" Height="19" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
                        <Path x:Name="Background" Width="Auto" Height="Auto" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="{DynamicResource BrushExpanderButtonStroke}" Data="{DynamicResource IconExpanderButtonExpandBackground}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{DynamicResource BrushExpanderButtonExpandBackground}" />
                        <Path x:Name="BackgroundEffectTop" Width="Auto" Height="Auto" Canvas.Left="2.2" Canvas.Top="1.2" Stretch="Fill" Data="{DynamicResource IconExpanderButtonExpandTopEffect}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2.5,1.2,2.5,6.2" Fill="{DynamicResource BrushExpanderButtonExpandTopEffectBackground}" />
                        <Path x:Name="BackgroundEffectBottom" Width="Auto" Height="Auto" Canvas.Left="1.5" Canvas.Top="1.4" Stretch="Fill" Data="{DynamicResource IconExpanderButtonExpandBottomEffect}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1.4,1.8,1.4,1.4" Fill="{DynamicResource BrushExpanderButtonExpandBottomEffectBackground}" />
                        <Viewbox x:Name="IcoPinar" Margin="3.4,2.2,1.6,0" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                            <Viewbox.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                    <SkewTransform AngleX="0" AngleY="0"/>
                                    <RotateTransform Angle="45"/>
                                    <TranslateTransform X="0" Y="0"/>
                                </TransformGroup>
                            </Viewbox.RenderTransform>
                            <Canvas Width="14.7577" Height="14.7578" RenderTransformOrigin="0.5,0.5" x:Name="canvas">
                                <Canvas.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="0"/>
                                        <TranslateTransform X="0" Y="0"/>
                                    </TransformGroup>
                                </Canvas.RenderTransform>
                                <Path x:Name="Icon1" Width="6.2149" Height="6.2149" Canvas.Left="0" Canvas.Top="8.54285" Stretch="Fill" StrokeLineJoin="Round" Stroke="{DynamicResource BrushExpanderButtonIconStroke}" Fill="{DynamicResource BrushExpanderButtonIconBackground}" Data="F1 M 2.00262,14.2578L 0.5,12.7552L 4.21228,9.04285L 5.7149,10.5455L 2.00262,14.2578 Z "/>
                                <Path x:Name="Icon2" Width="11.6067" Height="11.6066" Canvas.Left="1.50696" Canvas.Top="1.64417" Stretch="Fill" StrokeMiterLimit="2.75" Stroke="{DynamicResource BrushExpanderButtonIconStroke}" Fill="{DynamicResource BrushExpanderButtonIconBackground}" Data="F1 M 8.14999,2.14417L 12.6136,6.60776L 8.63611,10.5853L 9.34323,11.2924L 7.88483,12.7508L 2.00696,6.87296L 3.46539,5.41455L 4.17249,6.12164L 8.14999,2.14417 Z "/>
                                <Path x:Name="Icon3" Width="8.77814" Height="8.77811" Canvas.Left="5.97955" Canvas.Top="0" Stretch="Fill" StrokeLineJoin="Round" Stroke="{DynamicResource BrushExpanderButtonIconStroke}" Fill="{DynamicResource BrushExpanderButtonIconBackground}" Data="F1 M 8.11469,0.5L 14.2577,6.64297L 12.6225,8.27811L 6.47955,2.13513L 8.11469,0.5 Z "/>
                            </Canvas>
                        </Viewbox>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Fill" Value="{DynamicResource BrushExpanderButtonIconBackgroundHover}" TargetName="Icon1"/>
                            <Setter Property="Fill" Value="{DynamicResource BrushExpanderButtonIconBackgroundHover}" TargetName="Icon2"/>
                            <Setter Property="Fill" Value="{DynamicResource BrushExpanderButtonIconBackgroundHover}" TargetName="Icon3"/>
                            <Setter Property="Margin" TargetName="IcoPinar" Value="3.4,2.2,1.6,0"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="RenderTransform" TargetName="IcoPinar">
                                <Setter.Value>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="0"/>
                                        <TranslateTransform X="0" Y="0"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" TargetName="IcoPinar" Value="3.2,1.9,1.8,0"/>
                            <Setter Property="ToolTip" Value="{DynamicResource Infra.UI.Tooltip.DestravaExpander}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="ToolTip" Value="{DynamicResource Infra.UI.Tooltip.TravaExpander}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Fill" TargetName="Background" Value="{DynamicResource BrushExpanderBackgroundDisabled}" />
                            <Setter Property="Fill" TargetName="BackgroundEffectBottom" Value="{DynamicResource BrushExpanderBackgroundEffectBottomDisabled }"/>
                            <Setter Property="Stroke" TargetName="Background" Value="{DynamicResource BrushExpanderBackgroundStrokeDisabled}"/>
                            <Setter Property="Margin" TargetName="BackgroundEffectBottom" Value="1,1,1,1"/>
                            <Setter Property="Fill" TargetName="Icon1" Value="{DynamicResource BrushExpanderBackgroundIconDisabled}"/>
                            <Setter Property="Fill" TargetName="Icon2" Value="{DynamicResource BrushExpanderBackgroundIconDisabled}"/>
                            <Setter Property="Fill" TargetName="Icon3" Value="{DynamicResource BrushExpanderBackgroundIconDisabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ControlButtonExpanderExpand" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Grid Width="19" Height="19" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
                        <Path x:Name="Background" Width="Auto" Height="Auto" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="{DynamicResource BrushExpanderButtonStroke}" Data="{DynamicResource IconExpanderButtonExpandBackground}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{DynamicResource BrushExpanderButtonExpandBackground}" />
                        <Path x:Name="BackgroundEffectTop" Width="Auto" Height="Auto" Canvas.Left="2.2" Canvas.Top="1.2" Stretch="Fill" Data="{DynamicResource IconExpanderButtonExpandTopEffect}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2.5,1.2,2.5,6.2" Fill="{DynamicResource BrushExpanderButtonExpandTopEffectBackground}" />
                        <Path x:Name="BackgroundEffectBottom" Width="Auto" Height="Auto" Canvas.Left="1.5" Canvas.Top="1.4" Stretch="Fill" Data="{DynamicResource IconExpanderButtonExpandBottomEffect}" Fill="{DynamicResource BrushExpanderButtonExpandBottomEffectBackground}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="1.4,1.8,1.4,1.4" />
                        <Path x:Name="Icon" Width="13.2" Height="7.2" Canvas.Left="2.85" Canvas.Top="6.2" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="{DynamicResource BrushExpanderButtonIconStroke}" Fill="{DynamicResource BrushExpanderButtonIconBackground}" Data="{DynamicResource IconExpanderButtonExpand}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" Margin="0,0.7,0,0">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="1" ScaleY="-1"/>
                                    <SkewTransform AngleX="0" AngleY="0"/>
                                    <RotateTransform Angle="0"/>
                                    <TranslateTransform X="0" Y="0"/>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Fill" Value="{DynamicResource BrushExpanderButtonIconBackgroundHover}" TargetName="Icon"/>
                            <Setter Property="Fill" Value="{DynamicResource BrushExpanderButtonExpandBottomEffectBakgroundHover}" TargetName="BackgroundEffectBottom"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="ToolTip" Value="{DynamicResource Infra.UI.Tooltip.ContrairExpander}"/>
                            <Setter Property="RenderTransform" TargetName="Icon">
                                <Setter.Value>
                                    <TransformGroup>
                                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                                        <SkewTransform AngleX="0" AngleY="0"/>
                                        <RotateTransform Angle="0"/>
                                        <TranslateTransform X="0" Y="0"/>
                                    </TransformGroup>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" TargetName="Icon" Value="0,0,0,1.7"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="False">
                            <Setter Property="ToolTip" Value="{DynamicResource Infra.UI.Tooltip.ExpandirExpander}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Fill" TargetName="Background" Value="{DynamicResource BrushExpanderBackgroundDisabled}" />
                            <Setter Property="Fill" TargetName="BackgroundEffectBottom" Value="{DynamicResource BrushExpanderBackgroundEffectBottomDisabled }"/>
                            <Setter Property="Stroke" TargetName="Background" Value="{DynamicResource BrushExpanderBackgroundStrokeDisabled}"/>
                            <Setter Property="Margin" TargetName="BackgroundEffectBottom" Value="1,1,1,1"/>
                            <Setter Property="Fill" TargetName="Icon" Value="{DynamicResource BrushExpanderBackgroundIconDisabled}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Controls:SinacorExpander}">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Width" Value="Auto"/>
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:SinacorExpander}">
                    <Grid x:Name="Grid" Margin="0" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" VerticalAlignment="{TemplateBinding VerticalAlignment}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="22"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" x:Name="HeaderBorder" Margin="1,0,1,0" Background="{DynamicResource BrushExpanderBackground}" CornerRadius="8,8,0,0" SnapsToDevicePixels="true" HorizontalAlignment="Stretch" VerticalAlignment="Top" BorderBrush="{DynamicResource BrushExpanderContentBorder}" BorderThickness="{TemplateBinding BorderThickness}" Width="Auto" Height="22">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="50"/>
                                </Grid.ColumnDefinitions>
                                <!--Begin Header-->
                                <TextBlock Grid.Row="0" Margin="13,3.5,0,0" Grid.Column="0" Text="{TemplateBinding Header}" FontWeight="Bold" HorizontalAlignment="Left" Foreground="{DynamicResource BrushExpanderTitleForeground}" Style="{DynamicResource ControlFont}"/>
                                <StackPanel x:Name="Buttons" Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="0,0,5,0" HorizontalAlignment="Right">
                                    <ToggleButton x:Name="PART_ButtonPin" Visibility="Collapsed"  Height="20" Width="19" Style="{DynamicResource ControlButtonExpanderPin}" IsChecked="{Binding Path=IsPinned, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                    <ToggleButton x:Name="PART_ButtonExpand" Height="19" Width="19" Style="{DynamicResource ControlButtonExpanderExpand}" Margin="3.5,0,0,0" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </StackPanel>
                                <!--End Header-->
                            </Grid>
                        </Border>
                        <Border x:Name="ExpandSiteBorder" Width="Auto" Grid.Row="1" BorderThickness="1,0,1,1" SnapsToDevicePixels="True" BorderBrush="{DynamicResource BrushExpanderContentBorder}" CornerRadius="0,0,8,8"  Margin="1,0,1,0" Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="ContentPres" Margin="10,7,10,10" Width="{TemplateBinding Width}" Focusable="False" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Background" Value="{DynamicResource BrushExpanderDisabledBackground}" TargetName="HeaderBorder" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BrushExpanderBackground}" TargetName="HeaderBorder" />
                        </Trigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding HorizontalSplitter.IsVisible, RelativeSource={RelativeSource Self}}" Value="True"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Visibility" Value="Visible" TargetName="PART_ButtonPin"/>
                        </MultiDataTrigger>

                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding VerticalSplitter.IsVisible, RelativeSource={RelativeSource Self}}" Value="True"/>
                            </MultiDataTrigger.Conditions>
                            <Setter Property="Visibility" Value="Visible" TargetName="PART_ButtonPin"/>
                        </MultiDataTrigger>

                        <Trigger Property="AllowExpand" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="PART_ButtonExpand"/>
                        </Trigger>

                        <Trigger Property="IsExpanded" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ExpandSiteBorder"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!--END EXPANDER-->
</ResourceDictionary>

